package javaLanguage.javaMultithread;

import java.util.concurrent.*;

public class multiThread extends Thread{

    public multiThread() {
        this.setName("初始线程");
    }
    public void run() {
        while(true){
            System.out.println(Thread.currentThread().getName());
            try{
                Thread.sleep(10000);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        // 通过线程池实现多线程
        ThreadPoolExecutor temp = new ThreadPoolExecutor(10, 20, 1000, TimeUnit.MILLISECONDS, new LinkedBlockingDeque<>());
        temp.execute(new multiThread());
        //        multiThread3 temp = new multiThread3();
        //        FutureTask a = new FutureTask<>(temp);
        //        new Thread(a).start();
    }
}

class multiThreadRunable implements Runnable{

    public void run(){
        System.out.println(Thread.currentThread().getName());
        try{
            Thread.sleep(1000);
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class multiThreadCallable implements Callable<String>{
    @Override
    public String call() throws Exception {
        System.out.println(Thread.currentThread().getName());
        return null;
    }
}

